package com.ruoyi.project.flow.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.project.flow.domain.FlowFeedback;
import com.ruoyi.project.flow.service.IFlowFeedbackService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.SecurityUtils;

import java.util.Date;

/**
 * 反馈Controller
 *
 * @author zyc
 * @date 2025-05-12
 */
@Api(value = "/flow/feedback", tags = {"反馈"})
@RestController
@RequestMapping("/flow/feedback")
public class FlowFeedbackController extends BaseController {
    @Autowired
    private IFlowFeedbackService flowFeedbackService;

    /**
     * 查询反馈列表
     */
    @ApiOperation(value = "查询反馈列表")
    @ApiImplicitParams({
            @ApiImplicitParam(dataTypeClass = FlowFeedback.class, paramType = "body", dataType = "FlowFeedback", name = "flowFeedback", value = "the flowFeedback to list")
    })
    @GetMapping("/list")
    public TableDataInfo list(FlowFeedback flowFeedback) {
        startPage();
        List<FlowFeedback> list = flowFeedbackService.selectFlowFeedbackList(flowFeedback);
        return getDataTable(list);
    }

    /**
     * 导出反馈列表
     */
    @ApiOperation(value = "导出反馈列表")
    @ApiImplicitParams({
            @ApiImplicitParam(dataTypeClass = FlowFeedback.class, paramType = "body", dataType = "FlowFeedback", name = "flowFeedback", value = "the flowFeedback")
    })
    @Log(title = "反馈", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FlowFeedback flowFeedback) {
        List<FlowFeedback> list = flowFeedbackService.selectFlowFeedbackList(flowFeedback);
        ExcelUtil<FlowFeedback> util = new ExcelUtil<FlowFeedback>(FlowFeedback.class);
        util.exportExcel(response, list, "反馈数据");
    }

    /**
     * 获取反馈详细信息
     */
    @ApiOperation(value = "获取反馈详细信息")
    @GetMapping(value = "/{ID}")
    public AjaxResult getInfo(@PathVariable("ID") Long ID) {
        return AjaxResult.success(flowFeedbackService.selectFlowFeedbackByID(ID));
    }

    /**
     * 新增反馈
     */
    @ApiOperation(value = "新增反馈")
    @Log(title = "反馈", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FlowFeedback flowFeedback) {
        return toAjax(flowFeedbackService.save(flowFeedback));
    }

    /**
     * 修改反馈
     */
    @ApiOperation(value = "修改反馈 ")
    @Log(title = "反馈", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FlowFeedback flowFeedback) {
        return toAjax(flowFeedbackService.updateById(flowFeedback));
    }

    /**
     * 删除反馈
     */
    @ApiOperation(value = "删除反馈")
    @Log(title = "反馈", businessType = BusinessType.DELETE)
    @DeleteMapping("/{IDs}")
    public AjaxResult remove(@PathVariable Long[] IDs) {
        return toAjax(flowFeedbackService.deleteFlowFeedbackByIDs(IDs));
    }
}
